package org.lee.status.app;

import org.lee.status.app.activity.Status;
import org.lee.status.app.event.*;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * StateHandler
 * 状态处理
 *
 * @author dralee
 * @date 2021-11-24 09:43:11
 **/
public class StateHandler {
    private Map<Status, State> stateMap = new ConcurrentHashMap<>();

    public StateHandler() {
        stateMap.put(Status.EDITING, new EditingState());
        stateMap.put(Status.CHECK, new CheckState());
        stateMap.put(Status.PASS, new PassState());
        stateMap.put(Status.REFUSE, new RefuseState());
        stateMap.put(Status.DOING, new DoingState());
        stateMap.put(Status.OPEN, new OpenState());
        stateMap.put(Status.CLOSE, new CloseState());
    }


    public Result arraignment(String activityId, Status currentStatus) {
        return stateMap.get(currentStatus).arraignment(activityId, currentStatus);
    }

    public Result checkPass(String activityId, Status currentStatus) {
        return stateMap.get(currentStatus).checkPass(activityId, currentStatus);
    }

    public Result checkRefuse(String activityId, Status currentStatus) {
        return stateMap.get(currentStatus).checkRefuse(activityId, currentStatus);
    }

    public Result checkRevoke(String activityId, Status currentStatus) {
        return stateMap.get(currentStatus).checkRevoke(activityId, currentStatus);
    }

    public Result close(String activityId, Status currentStatus) {
        return stateMap.get(currentStatus).close(activityId, currentStatus);
    }

    public Result open(String activityId, Status currentStatus) {
        return stateMap.get(currentStatus).open(activityId, currentStatus);
    }

    public Result doing(String activityId, Status currentStatus) {
        return stateMap.get(currentStatus).doing(activityId, currentStatus);
    }
}
